package ext.db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

import org.springframework.jdbc.core.PreparedStatementCreator;

public class GenerarerIdSaveCreator implements PreparedStatementCreator{

	private String sql;
	
	private Object[] params;
	
	@Override
	public PreparedStatement createPreparedStatement(Connection con)
			throws SQLException {
		PreparedStatement statement = con.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
		for (int j = 0; j <params.length; j++)
			statement.setObject((j+1),params[j]);
		return statement;
	}

	public GenerarerIdSaveCreator(String sql, Object[] params) {
		this.sql = sql;
		this.params = params;
	}

}
